#!/bin/sh
#
# This is just a script for fun, it'll check for the cd-rom in a very
# non-efficient way, & issue the eject command on the results.
#

# 1st, test for the command...
which eject; test_results = $?;

if [ ${test_results} -eq 1 ]; then
  echo "The eject command does not exist on this machine"
else
  # take a best guess at the systems cdrom drive
  cd_drive = $(dmesg | grep -i CD-ROM | cut -d: -f1 | grep hd)
  eject ${cd_drive}
  # maybe they use scsi instead of ide?
  scsi_drive = $(dmesg | grep -i CD-ROM | cut -d: -f1 | grep sd)
  eject ${scsi_drive}
fi